package com.tanhua.server.controller;

import com.tanhua.model.vo.PageResult;
import com.tanhua.server.interceptor.UserHolder;
import com.tanhua.server.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @auther : 白月尘
 * @date : 16:39  2021/10/21
 */
@RestController
@RequestMapping("/comments")
public class CommentController {

    @Autowired
    private CommentsService commentsService;


    @GetMapping
    public ResponseEntity comments(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer pagesize,
                                   String movementId){
        PageResult pageResult=commentsService.comments(page,pagesize,movementId);
        return ResponseEntity.ok(pageResult);
    }
    //评论-提交-对动态评论
    @PostMapping
    public ResponseEntity comments(@RequestBody Map map){
        commentsService.checkFreezeState(UserHolder.getUserId(),map);
        //commentsService.subComments(map);
        return ResponseEntity.ok(null);
    }
}
